package com.gdufe.mistakebook.mapper;

import com.gdufe.mistakebook.entity.Label;
import com.gdufe.mistakebook.entity.vo.QueryLabelsVo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lzh
 */
@Mapper
public interface LabelMapper {



    /**
     * 根据用户id 与 标签名 查询标签
     *
     * @param labelName
     * @param userId
     */
    @Select("select * from mistake_book.label where user_id = #{userId} and label_name = #{labelName}")
    Label getLabelByName(String labelName, int userId);


    int insertLabel(Label label);

    /**
     * 根据ID列表批量查询标签名
     *
     * @param labelIds
     * @return
     */
    List<String> getLabelNamesByIds(@Param("labelIds") List<Integer> labelIds);

    /**
     * 更新标签信息
     * @param label
     */

    void update(Label label);

    @Select("select * from mistake_book.label where id = #{id}")
    Label getLabelById(int id);

    @Select("select label_name from mistake_book.label where status=1 and user_id = #{userId}")
    List<String> getLabelName(int userId);

    @Select("select id from mistake_book.label where status=1 and user_id = #{userId}")
    List<String> getLabelIds(int userId);

    Page<QueryLabelsVo> QueryLabels(@Param("userId") Integer userId,@Param("key") String key);
}




